<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<p>用户名：<input type="text" id="username" /></p>
		<p>密码：<input type="password" id="pwd" /></p>
		<input type="button" value="登陆" onclick="login()" />
		<a href="reg.html">注册账号</a>
		<table border="1" cellspacing="0" cellpadding="0">
			<tr>
				<th>用户名</th>
				<th>密码</th>
			</tr>
			<tr>
				<td>123132</td>
				<td>123123</td>
			</tr>
			<tr>
				<td>zhengyuda</td>
				<td>123</td>
			</tr>
			<tr>
				<td>567567</td>
				<td>567567</td>
			</tr>
		</table>
		<script src="js/jmessage-sdk-web-2.1.0.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/Cookie.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var JIM = new JMessage();
			window.onload = function() {
				init();
			}
			function init() {
				JIM.init({
					"appkey": "239a00294f23757f90151429",
					"random_str": "022cd9fd995849b58b3ef0e943421ed9",
					"signature": "D97C2DDA3E46E5E6D482E9E8EE84AF93",
					"timestamp": "1467967210887"
				}).onSuccess(function(data) {
					//					console.log('success:' + JSON.stringify(data));
				}).onFail(function(data) {
					console.log('error:' + JSON.stringify(data))
				});
			}

			function login() {
				var username = $("#username").val();
				var pwd = $("#pwd").val();
				JIM.login({
					'username': username,
					'password': pwd
				}).onSuccess(function(data) {
					console.log("登陆成功");
					setCookie(username, pwd);
						location.href = "talking.html";
					console.log('success:' + JSON.stringify(data));
				}).onFail(function(data) {
					console.log("登陆失败");
					console.log('error:' + JSON.stringify(data));
				}).onTimeout(function(data) {
					console.log("登陆超时");
					console.log('timeout:' + JSON.stringify(data));
				});
			}
		</script>
	</body>

</html>